package aspectos;

import java.util.HashMap;

import annotations.Monitored;

public aspect ContadorAspect pertarget(call(@Monitored * *.*(..))){
	
	pointcut evento() : 
		execution(@Monitored * *.*(..));
		
    after() : evento() {
    	aumentarContador(thisJoinPoint.getSignature().getName());
    }
    
    private HashMap<String, Integer> m = new HashMap<String, Integer>();
    
    protected void aumentarContador(String key) {
    	if(m.containsKey(key)){
    		m.put(key, m.get(key)+1);
    	}else{
    		m.put(key, 1);
    	}
    }
    
    public Integer cantLlamadas(String metodo){
    	return (m.get(metodo));
    }
}
